﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLab.Controllers.SolutionExplorer;
using System.Windows.Controls;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using Microsoft.Practices.Prism.ViewModel;
using Microsoft.Practices.Prism.Regions;
using QLab.UserControls;
using System.Windows;

namespace QLab.Controllers
{
	/// <summary>
	/// Klasa zadužena za rad aplikacije
	/// </summary>
	[Export]
	[PartCreationPolicy(CreationPolicy.Shared)]
	public class MainWindowController : NotificationObject
	{
		private MainWindow _view;
		private IRegionManager _regionManager;

		private TabController _tabController;
		private RibbonController _ribbonController;

		private SolutionExplorerController _solutionExplorerController;
		private TextBlock _statusBar;

		private ICompositionService _compositionContainer;

		[ImportingConstructor]
		private MainWindowController(IRegionManager RegionManager)
		{
			_regionManager = RegionManager;
			_regionManager.RegisterViewWithRegion(RegionNames.SolutionExplorerRegion, typeof(SolutionExplorerView));
			_regionManager.RegisterViewWithRegion(RegionNames.RibbonRegion, typeof(RibbonView));
			_regionManager.RegisterViewWithRegion(RegionNames.ConsoleRegion, typeof(ConsoleView));

			//_tabController = new TabController(_view.tabContainer);
			//_ribbonController = new RibbonController(_view.ribbon);

			//_solutionExplorerController = new SolutionExplorer.SolutionExplorerController(_view.solutionExplorerView);

			//_statusBar = _view.statusBar;
		}

		#region Properties

		public TextBlock StatusBar
		{
			get { return _statusBar; }
		}

		public SolutionExplorerController SolutionExplorerController
		{
			get { return _solutionExplorerController; }
		}

		public TabController TabController
		{
			get { return _tabController; }
		}

		public RibbonController RibbonController
		{
			get { return _ribbonController; }
		}

		public MainWindow View
		{
			get { return _view; }
			set
			{
				_view = value;
				RaisePropertyChanged(() => View);
			}
		}
		#endregion

		#region Methods

		public void CloseApplication()
		{
			Application.Current.Shutdown();
		}

		#endregion
	}
}
